package com.example.rightmost.controller.user;

import com.example.rightmost.entity.Topic;
import com.example.rightmost.entity.TopicCategory;
import com.example.rightmost.service.CategoryService;
import com.example.rightmost.service.TopicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author:javayhch
 * @date:2024/8/20
 * @description:
 */

@RestController
@RequestMapping("/user/topic")
public class TopicController {

    @Autowired
    public CategoryService categoryService;

    @Autowired
    public TopicService topicService;

    @RequestMapping("/getTabs")
    public List<TopicCategory> getTabs(){
        List<TopicCategory> list = categoryService.getTabs();
        return list;
    }

    @RequestMapping("/getTopics")
    public List<Topic> getTopics(@RequestBody Topic topic){
        List<Topic> list = topicService.getTopicList(topic);
        return list;
    }

    @RequestMapping("/getTopic")
    public Topic getTopic(@RequestParam int id){
        Topic topic = topicService.getTopic(id);
        return topic;
    }


}
